#include "CustomSort.h"
#include <iostream>
using namespace std;

void sort(int* array, int size) {
  for (int i = size - 1; i >= 0; i--) {
    for (int j = 0; j < i; j++) {
      if (array[j] > array[j+1]) {
        int x = array[j];
        array[j] = array[j + 1];
        array[j + 1] = x;
      }
    }
  }
}

bool isSorted(int* array, int size) {
   for (int i = 0; i < size - 1; i++) {
      if (array[i] > array[i + 1]) {
         return false;
      }
   }
   return true;
}

void print(int* array, int size) {
   cout << "[";
   for (int i = 0; i < size - 1; i++) {
	std::cout << array[i] << ", ";
   }
   if (size > 0) {
      cout << array[size - 1];
   }
   cout << "]" << endl;
}

int main() {
   int nums[5] = {1, 6, 8, -3, 0};
   print(nums, 5);
   cout << "isSorted(): " << isSorted(nums, 5) << endl << "Sorting..." << endl;
   sort(nums, 5);
   print(nums, 5);
   cout << "isSorted(): " << isSorted(nums, 5) << endl;
}
